import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:share_fit/app/components/back_btn_icon.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/tools/color_const.dart';
import 'package:share_fit/generated/locales.g.dart';

import 'sms_remind_logic.dart';

class SmsRemindPage extends StatelessWidget {
  SmsRemindPage({super.key});

  final logic = Get.put(SmsRemindLogic());
  final state = Get.find<SmsRemindLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(LocaleKeys.settings_sms_remind.ts, style: TextStyle(fontSize: 54.sp, color: ColorConst.btnFontColor),),
        centerTitle: true,
        leading: BackBtnIcon(onTap: () => Get.back()),
        // leading: IconButton(
        //   padding: EdgeInsets.only(left: 40.w,),
        //   icon: Image.asset("assets/images/space/icon_appbar_arrow_back.png"),
        //   onPressed: () { Get.back(); },
        //   // child: Image.asset("images/icon_appbar_arrow_back.png"),
        // ),
        // leadingWidth: 25,
      ),
      body: Column(
        children: [
          Container(height: 99.h,),
          Image(
            width: 782.w,
            height: 290.h,
            image: const AssetImage("assets/images/device/icon_sms_remind.png"),),
          Container(
            margin: EdgeInsets.fromLTRB(42.w, 100.h, 42.w, 0),
            padding: EdgeInsets.fromLTRB(60.w, 64.h, 36.w, 64.h),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(10),
              color: Colors.white
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    GetBuilder<SmsRemindLogic>(
                        id: 'sms_remind_switch',
                        builder: (value) {
                          return Text(state.smsSwitchValue?LocaleKeys.call_remind_on.ts:LocaleKeys.call_remind_off.ts, style: TextStyle(fontSize: 42.sp, color: ColorConst.btnFontColor),);
                        }),
                    GetBuilder<SmsRemindLogic>(
                        id: 'sms_remind_switch',
                        builder: (value) {
                          return Transform.scale(
                            scale: 0.7,
                            child: CupertinoSwitch(value: state.smsSwitchValue, activeColor: ColorConst.activeColor,
                                onChanged: (value) {
                                  logic.updateSmsSwitch(value);
                                }),);
                    })
                  ],),
                Text(LocaleKeys.sms_remind_tips.ts, style: TextStyle(fontSize: 36.sp, color: Color(0xFF898C8F)),)
              ],
            ),
          ),
        ],
      ),
    );
  }
}
